#include <cstdio>

typedef char TElemType;

typedef struct node {
    TElemType data;
    struct node *left_child;
    struct node *right_child;
} BTNode, *BinTree;

//TElemType ch[] = { 'A', 'B', '#', 'D', '#', '#', 'C', 'E', '#', '#', 'F', '#', '#' };
//DEH##FJ##G#CK###A#B##
TElemType ch[] = { 'D', 'E', 'H', '#', '#', 'F', 'J', '#', '#', 'G', '#', 'C', 'K', '#', '#', '#', 'A', '#', 'B', '#', '#' };
int count = 0;

void Create( BTNode*& t ) {
    char c;
    c = ch[count++];
    if( c =='#' )
        t = NULL;
    else {
        t = new BTNode;
        t->data = c;
        Create( t->left_child );
        Create( t->right_child );
    }
}

void PreOrder( BTNode* t ) {
    if( t != NULL ) {
        printf( " %c", t->data );
        PreOrder( t->left_child );
        PreOrder( t->right_child );
    }
}

void InOrder( BTNode *t ) {
    if( t != NULL ) {
        InOrder( t->left_child );
        printf( " %c", t->data );
        InOrder( t->right_child );
    }
}

void PostOrder( BTNode *t ) {
    if( t != NULL ) {
        PostOrder( t->left_child );
        PostOrder( t->right_child );
        printf( " %c", t->data );
    }
}

int main() {
    BTNode T;
    BinTree root = &T;
    Create( root );
    printf( "PreOrder:" );
    PreOrder( root );
    printf( "\n" );
    printf( "InOrder:" );
    InOrder( root );
    printf( "\n" );
    printf( "PostOrder:" );
    PostOrder( root );
    return 0;
}